//
//  WProViewCell.swift
//  iiatn
//
//  Created by mnine on 18/3/31.
//  Copyright © 2018年 mnine. All rights reserved.
//

import UIKit

class WProViewCell: UITableViewCell {

    @IBOutlet weak var proimage: UIImageView!
    
    @IBOutlet weak var protitle: UILabel!
    
    @IBOutlet weak var proamount: UILabel!
    
    @IBOutlet weak var prodidian: UILabel!
    
    @IBOutlet weak var prohangye: UILabel!
    
    @IBOutlet weak var proclick: UILabel!
    
    var proItem: WPro? {
        didSet {
            let url = proItem!.thumb
            if (url!.isEmpty){
                proimage.image = UIImage(named:"default_bg")
            }else{
                proimage.kf.setImage(with: URL(string: url!)!, placeholder: UIImage(named: "default_bg"), options: nil, progressBlock: nil)
            }
            
            protitle.text = proItem!.title
            
            if proItem!.isshow == 0 {
                proclick.text = "审核状态：待处理"
            }else {
                proclick.text = "阅读量:\(proItem!.click_num!)"
            }

            proamount.text = "金额:\(proItem!.amount_money!)万美元"
            //str.components(separatedBy:".")
            let filt = proItem!.filterattr_value?.components(separatedBy: "|")
            if (filt?.count)! > 0 {
                prodidian.text = "地点:\((proItem!.filterattr_value?.components(separatedBy: "|")[0])!)"
            }
            if (filt?.count)! > 1{
                prohangye.text = "行业:\((proItem!.filterattr_value?.components(separatedBy: "|")[1])!)"
            }   
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        self.width = SCREENW
        protitle.width = SCREENW - 220
        prodidian.width = SCREENW - 220
        prohangye.width = SCREENW - 220
        proamount.width = SCREENW - 220
        proimage.x = 5
        proimage.layer.cornerRadius = kCornerRadius
        proimage.layer.masksToBounds = true
        proimage.layer.shouldRasterize = true
        proimage.layer.rasterizationScale = UIScreen.main.scale
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
